//chika和蜜柑、NC145 01背包

//chika和蜜柑:https://ac.nowcoder.com/acm/problem/26221
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;

const int N = 2e5+10;

pair<int,int> arr[N];


bool cmp(const pair<int,int>& a,const pair<int,int>& b)
{
    if(a.second != b.second)
        return a.second > b.second;
    else
        return a.first < b.first;
}

int main()
{
    int n,k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i].first;
    }
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i].second;
    }
    
    sort(arr,arr+n,cmp);
    
    long long s = 0, t = 0;
    for(int i = 0; i < k; i++)
    {
        s += arr[i].first;
        t += arr[i].second;
    }
    
    cout << s << ' ' << t;
    return 0;
}


//NC145 01背包:https://www.nowcoder.com/practice/2820ea076d144b30806e72de5e5d4bbf?tpId=196&tqId=37561&ru=/exam/oj
class Solution {
public:
    int knapsack(int V, int n, vector<vector<int> >& vw) 
    {
        vector<int> dp(V+1,0);

        for(int i = 1; i <= n; i++)
        {
            for(int j = V; j >= vw[i-1][0]; j--)
            {
                dp[j] = max(dp[j],dp[j-vw[i-1][0]] + vw[i-1][1]);
            }

            for(int k = 1; k <= V; k++)
            {
                cout << dp[k] << ' ';
            }
            cout << endl;
        }
        return dp[V];
    }
};
//#include <stdio.h>
//#include <sys/types.h>
//#include <unistd.h>
//
//int main()
//{
//    printf("进程运行，pid: %d\n",getpid());
//    while(1)
//    {
//
//    }
//    return 0;
//}
